package com.jlc.book.shop.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCUtil {
	static{
		try{
			Class.forName("com.mysql.jdbc.Driver");
			//Class.forName("oracle.jdbc.driver.OracleDriver");
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public static Connection getMysqlConnection() throws SQLException{
		return DriverManager.getConnection("jdbc:mysql://localhost:3306/jlconlinebookdb","root","rks");
	}
	public static Connection getOracleConnection() throws SQLException{
		return DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","system","rks");
	}
	public static void Cleanup(Statement st,Connection con){
		try{
			if(st!=null) st.close();
			if(con!=null) con.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	public static void Cleanup(ResultSet rs,Statement st,Connection con){
		try{
			if(rs!=null) rs.close();
			if(st!=null) st.close();
			if(con!=null) con.close();
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
